package TestSynchronized;

/**
 * @Author Mr.Wen
 * @Version 1.0
 */
public class TestInterrupt {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            while (true) {
                System.out.println("t1在运行...");
                if (Thread.currentThread().isInterrupted()) {
                    System.out.println("t1中断了");
                    break;
                }
            }
        }, "t1");
        t1.start();

        new Thread(() -> {
            t1.interrupt();
            System.out.println(Thread.interrupted());
        }, "t2").start();
    }
}
